package codesound;
import codesound.lexer.parser.Parser;
import codesound.lexer.lexer.*;
import codesound.lexer.node.*;
import javax.sound.midi.*;
import java.io.*;


public class Compiler{
	
	public static void main(String[] arguments)
	{
		
		try
		{			
			// Create a Parser instance.
			Parser p = new Parser(new Lexer(new PushbackReader(new FileReader("text.in"), 1024)));
			// Parse the input
			Start tree = p.parse();//System.out.println(tree);
			// Apply the translation.
			System.out.println("Trollol");
			tree.apply(new Translation());
			//System.out.println(Helper.ensam);

			//Saving
			
			try{
					MidiSystem.write(Helper.sq, 0, new File("Example.midi"));
				}catch(IOException e){
				System.out.println("Di error");
					e.printStackTrace();
				}
			
			
			
			// try{
				// BufferedWriter bw = new BufferedWriter(new FileWriter("ensam.txt"));
				// bw.write(Helper.ensam.toString());
				// bw.close();
			// }catch (Exception ex) {ex.printStackTrace();}

			
			}
		catch(Exception e)
			{
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
		
		
	}

}